String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

String.prototype.replaceAll = function( searchStr, replaceStr )
{
	var temp = this;
	return temp.split( searchStr ).join( replaceStr );
}

function parseXml(xml) { 
   var localDebug = false;
   
   var dom = null;
   if (window.DOMParser) {
      try { 
         dom = (new DOMParser()).parseFromString(xml, "text/xml"); 
      } catch (e) { 
          dom = null; 
      }
   } else if (window.ActiveXObject) {
      try {
         dom = new ActiveXObject('Microsoft.XMLDOM');
         dom.async = false;
         if (!dom.loadXML(xml)) { 
        	// parse error ..
        	if( localDebug ) { 
        	    window.alert(dom.parseError.reason + dom.parseError.srcText);
        	}
         }
      }catch (e) {
          dom = null; 
      }
   } else { 
	  if( localDebug ) { 
		  alert("oops");
	  }
   }
   return dom;
}

function callAjax( url , params, onSuccessListener, onFailureListener , onCreateListener , onCompleteListener ) { 
    new Ajax.Request(
        url ,
        {
            asynchronous: false 
            , method: 'POST'  
            , encoding: 'UTF-8' 
            , "parameters" : params  
            , onCreate:  onCreateListener 
            , onComplete: onCompleteListener 
            , onFailure: onFailureListener 
            , onSuccess:  onSuccessListener
        }
    ) 
}
